package structure.Flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by LYJ on 2016/10/19.
 * 复合享元角色
 */
public class ConcreteCompositeFlyweight implements Flyweight {

    private Map<String,Flyweight> flyweightMap=new HashMap<>();
    public void add(String key,Flyweight flyweight){
        flyweightMap.put(key,flyweight);
    }

    @Override
    public void operation(String state) {
        Flyweight fly=null;
        for(String s:flyweightMap.keySet()){
            fly=flyweightMap.get(s);
            fly.operation(state);
        }

    }
}
